Skip to content

Unify descriptor managment into LiteBox core#722

Merged
jaybosamiya-ms merged 15 commits intomainfrom
jayb/fd-cleanup
Mar 17, 2026
Merged

Unify descriptor managment into LiteBox core#722
jaybosamiya-ms merged 15 commits intomainfrom
jayb/fd-cleanup

Conversation

@jaybosamiya-ms
Copy link
Copy Markdown
Member

@jaybosamiya-ms jaybosamiya-ms commented Mar 13, 2026

This PR fully eliminates the descriptor table indirection we had in the shim, now relying entirely on the LiteBox core to manage file descriptors both for raw FDs as well as the typed FDs.

To do this, I've made the following changes at the core litebox crate:

  • Explicitly started allowing for non-litebox crates to define FdEnabledSubsystems, as a stabilized interface
  • Exposed some public interfaces to interact more with the descriptor tables
  • Introduced a EntryHandle interface, that allows entry-specific locking outside litebox without maintaining a full descriptor table lock

At the shim, roughly it boils down to "remove Descriptors + Descriptor" and deal with the consequences. The changes are quite extensive but are not particularly insightful in any major way. I did clean up a few bugs along the way where (say) rlimits might not have been adhered to, or if two descriptors are made and the second one hit an rlimit issue, then there could have been a leak, etc.

Despite removing a chunk of code, some other code did get a tiny bit more bloated, but the level of indirection is smaller. I think we can further clean this up by removing some of the redundancy, but I think merging this in sooner than that is probably the better move, thus I've opened the PR in the current state.


Related: #31

These were intended to eventually be public, but were locked down in the past.  Now that things are a bit more stable, we can actually make these public.
This was a non-trivial change since it required migrating a bunch of code up to actually use raw FDs everywhere, but this should make the next commit (hopefully) simpler to read.
This gets rid of the `__Unused`, but introduces some clippy things to be cleaned up, but I wanted to keep this particular commit quite "obvious" on its own to see in the diff.
@jaybosamiya-ms jaybosamiya-ms marked this pull request as ready for review March 13, 2026 02:30
@jaybosamiya-ms jaybosamiya-ms requested a review from wdcui March 13, 2026 02:31
@github-actions
Copy link
Copy Markdown

🤖 SemverChecks 🤖 No breaking API changes detected

Note: this does not mean API is unchanged, or even that there are no breaking changes; simply, none of the detections triggered.

Copy link
Copy Markdown
Member

@wdcui wdcui left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel free to resolve my last comment and merge this PR when you are ready.

@jaybosamiya-ms jaybosamiya-ms added this pull request to the merge queue Mar 17, 2026
Merged via the queue into main with commit 9c0ab32 Mar 17, 2026
14 checks passed
@jaybosamiya-ms jaybosamiya-ms deleted the jayb/fd-cleanup branch March 17, 2026 00:15
sangho2 pushed a commit that referenced this pull request Mar 24, 2026
The descriptor unification in #722 lost the min_fd support for F_DUPFD.
do_dup() always allocated at the lowest available fd (ignoring min_fd),
then a post-hoc check failed because the allocated fd was below min_fd,
returning EMFILE. For example, /bin/sh calling fcntl(3, F_DUPFD, 10)
would get fd 4 allocated, then fail with 'Too many open files'.

Add fd_into_raw_integer_at_or_above() to RawDescriptorStorage and
thread min_fd through do_dup_inner so F_DUPFD allocates at fd >= min_fd.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants